
package com.ziyun.erp.web.modules.demo;

import io.renren.modules.sys.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.report.service.ErpReportService;


/**
 * @author zh
 * @date 2018/8/115:44
 */
@Slf4j
@RestController
@RequestMapping("demo")
public class DemoController {
	@Autowired
	private ErpReportService erpReportService;

	@Autowired
	private MailService mailService;

	@RequestMapping("/testMail")
	public void testMail() {
		String a = null;
		a.equals("0");
	}

	@RequestMapping("/testMail1")
	public void testMail1() {
        log.info("======================== 邮件发送测试 =========================");
        StringBuffer sb = new StringBuffer();
        sb.append("<html>\n");
        sb.append("<body>\n");
        sb.append("<h3>hello world!测试发送html格式邮件</h3>\n");
        sb.append("<div>&nbsp;&nbsp;&nbsp;&nbsp;hello world!测试发送html格式邮件111</div>\n");
        sb.append("</body>\n");
        sb.append("</html>");
		mailService.sendHtmlMail("guizhao@11ziyun.com","测试",sb.toString());
	}

	@RequestMapping("/test")
	public void test() {
	    log.info("123");
//		erpReportService.test();
	}

//    @Autowired
//    private CacheChannel cacheChannel;
//
//    @RequestMapping("/getMessage")
//    public Map getMessage(@RequestParam(value="webCount", defaultValue="1")int webCount) throws InterruptedException {
//        List<Map> list = new ArrayList<>();
//        while (true){ //保持连接
//            CacheObject cacheObject =  cacheChannel.get("default","messages");
//            if (cacheObject.getValue() !=null){
//                list = (List<Map>) cacheObject.getValue();
//            }
//            if (list.size() >0 && webCount !=list.size()){
//                break;
//            }
//            //todo 做睡眠 并且一定时间内释放连接
//            Thread.sleep(1000);
//        }
//        Map rs = new HashMap();
//        rs.put("count",list.size());
//        rs.put("items", list);
//        return rs;
//
//    }

}

